def add_simple(n):
    sum = 0
    for i in range(n + 1):
        sum += i
    return sum


# 返回从1 + ... + n到的结果，add_recursive(n - 1)从1 + ... + n - 1的结果
# 通项公式: f(n) = n + f(n - 1)
def add_recursive(n):
    if n < 1:
        print("传入的结果不合法")
        return -1
    if n == 1:
        return 1
    return n + add_recursive(n - 1)


# 1 1 2 3 5 8 13 21
# 返回斐波那契数列第n项的结果
# 通项公式: f(n) = f(n - 1) + f(n - 2)
def fibo(n):
    if n == 1:
        return 1
    if n == 2:
        return 1
    return fibo(n - 1) + fibo(n - 2)


if __name__ == "__main__":
    sum1 = add_simple(100)
    sum2 = add_recursive(100)
    print(sum1)
    print(sum2)
